package exercises;

/**
 * @author zerorain
 **/
import java.util.*;
//排序子序列  非递增或非递减  分情况讨论即可  注意越界问题。
public class ex4{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] arr = new int[n + 1];
        for(int j = 0; j < n ; j++){
            arr[j] = sc.nextInt();
        }
        int i = 0;
        int count = 0;
        while(i < n ){
            if(arr[i] > arr[i+1]){
                while(i < n && arr[i] > arr[i + 1]){
                    i++;
                }
                count ++;
                i++;
            } else if (arr[i] == arr[i+1]){
                i++;
            } else if (arr[i] < arr[i+1]){
                while(i < n && arr[i] < arr[i + 1]){
                    i++;
                }
                count ++;
                i++;
            }
        }
        System.out.println(count);
    }
}